From d28379e0ef8536bde8f961147aa6d7842409f7dd Mon Sep 17 00:00:00 2001 From: "kaf24@scramble.cl.cam.ac.uk" Date: Thu, 29 May 2003 11:47:59 +0000 Subject: [PATCH] bitkeeper revision 1.250 (3ed5f36fGoVK0VfvAjIbpFZ61R_U0A) desc.h, domain.c, mm.c: Fix start-of-day callback selectors so that they are not 0 -- this confuses some tests in entry.S. --- xen/arch/i386/mm.c | 4 ++-- xen/common/domain.c | 11 ++++++++++- xen/include/asm-i386/desc.h | 14 +++++++++++--- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/xen/arch/i386/mm.c b/xen/arch/i386/mm.c index 239aad1bbe..7bccd34f9c 100644 --- a/xen/arch/i386/mm.c +++ b/xen/arch/i386/mm.c @@ -103,8 +103,8 @@ long do_stack_switch(unsigned long ss, unsigned long esp) int nr = smp_processor_id(); struct tss_struct *t = &init_tss[nr]; - if ( (ss == __HYPERVISOR_CS) || (ss == __HYPERVISOR_DS) ) - return -1; + if ( !VALID_DATASEL(ss) ) + return -EINVAL; current->thread.ss1 = ss; current->thread.esp1 = esp; diff --git a/xen/common/domain.c b/xen/common/domain.c index 7938c2734b..19c26f986c 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -34,7 +34,7 @@ struct task_struct *task_hash[TASK_HASH_SIZE]; */ struct task_struct *do_newdomain(unsigned int dom_id, unsigned int cpu) { - int retval; + int retval, i; struct task_struct *p = NULL; unsigned long flags; @@ -68,6 +68,15 @@ struct task_struct *do_newdomain(unsigned int dom_id, unsigned int cpu) p->addr_limit = USER_DS; p->active_mm = &p->mm; + /* + * We're basically forcing default RPLs to 1, so that our "what privilege + * level are we returning to?" logic works. + */ + p->failsafe_selector = FLAT_RING1_CS; + p->event_selector = FLAT_RING1_CS; + p->thread.ss1 = FLAT_RING1_DS; + for ( i = 0; i < 256; i++ ) p->thread.traps[i].cs = FLAT_RING1_CS; + sched_add_domain(p); INIT_LIST_HEAD(&p->pg_head); diff --git a/xen/include/asm-i386/desc.h b/xen/include/asm-i386/desc.h index 6fc0cb7182..3155af3268 100644 --- a/xen/include/asm-i386/desc.h +++ b/xen/include/asm-i386/desc.h @@ -11,9 +11,17 @@ #define load_TR(n) __asm__ __volatile__ ("ltr %%ax" : : "a" (__TSS(n)<<3) ) -/* Guest OS must provide its own code selectors, or use the one we provide. */ -#define VALID_CODESEL(_s) \ - ((((_s)>>2) >= FIRST_DOMAIN_GDT_ENTRY) || ((_s) == FLAT_RING1_CS)) +/* + * Guest OS must provide its own code selectors, or use the one we provide. + * The RPL must be 1, as we only create bounce frames to ring 1. + */ +#define VALID_CODESEL(_s) \ + (((((_s)>>2) >= FIRST_DOMAIN_GDT_ENTRY) || ((_s) == FLAT_RING1_CS)) && \ + (((_s)&3) == 1)) + +#define VALID_DATASEL(_s) \ + (((((_s)>>2) >= FIRST_DOMAIN_GDT_ENTRY) || ((_s) == FLAT_RING1_DS)) && \ + (((_s)&3) == 1)) /* These are bitmasks for the first 32 bits of a descriptor table entry. */ #define _SEGMENT_TYPE (15<< 8) -- 2.30.2